/* 全局样式 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

body {
    background-color: #f5f7fa;
    color: #333;
    line-height: 1.6;
    overflow: hidden; /* 防止页面整体滚动 */
}

a {
    text-decoration: none;
    color: #3498db;
}

a:hover {
    color: #2980b9;
}

button {
    cursor: pointer;
    border: none;
}

/* 登录页面样式 */
.login-container {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    padding: 20px;
}

.login-box {
    background-color: #fff;
    border-radius: 10px;
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.1);
    width: 100%;
    max-width: 400px;
    padding: 30px;
}

.login-header {
    text-align: center;
    margin-bottom: 30px;
}

.login-header h1 {
    color: #2c3e50;
    margin-bottom: 10px;
}

.login-header p {
    color: #7f8c8d;
}

.tabs {
    display: flex;
    margin-bottom: 25px;
}

.tab-btn {
    flex: 1;
    padding: 12px;
    background-color: #ecf0f1;
    color: #7f8c8d;
    font-weight: 500;
    transition: all 0.3s ease;
}

.tab-btn.active {
    background-color: #3498db;
    color: white;
}

.tab-btn:hover:not(.active) {
    background-color: #dcdde1;
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    color: #2c3e50;
    font-weight: 500;
}

.input-icon {
    position: relative;
}

.input-icon input {
    width: 100%;
    padding: 12px 12px 12px 40px;
    border: 1px solid #bdc3c7;
    border-radius: 5px;
    font-size: 16px;
    transition: border 0.3s ease;
}

.input-icon i {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: #7f8c8d;
}

.input-icon input:focus {
    outline: none;
    border-color: #3498db;
}

.btn-primary {
    width: 100%;
    padding: 12px;
    background-color: #3498db;
    color: white;
    font-size: 16px;
    font-weight: 500;
    border-radius: 5px;
    transition: background-color 0.3s ease;
}

.btn-primary:hover {
    background-color: #2980b9;
}

.form-message {
    margin-top: 15px;
    padding: 10px;
    border-radius: 5px;
    text-align: center;
}

.form-message.success {
    background-color: #d5f5e3;
    color: #27ae60;
}

.form-message.error {
    background-color: #fadbd8;
    color: #e74c3c;
}

/* 聊天页面样式 - 核心优化部分 */
.chat-container {
    display: flex;
    height: 100vh;
    overflow: hidden;
}

.sidebar {
    width: 250px;
    background-color: #2c3e50;
    color: white;
    display: flex;
    flex-direction: column;
    overflow: hidden; /* 侧边栏内容溢出控制 */
}

.sidebar-header {
    padding: 20px;
    border-bottom: 1px solid #34495e;
}

.sidebar-menu {
    flex: 1;
    padding: 20px 0;
    overflow-y: auto;
    /* 滚动条美化 */
    scrollbar-width: thin;
    scrollbar-color: #34495e transparent;
}

.sidebar-menu::-webkit-scrollbar {
    width: 6px;
}

.sidebar-menu::-webkit-scrollbar-thumb {
    background-color: #34495e;
    border-radius: 3px;
}

.menu-item {
    padding: 15px 20px;
    display: flex;
    align-items: center;
    color: #ecf0f1;
    transition: background-color 0.3s ease;
}

.menu-item i {
    margin-right: 10px;
    width: 20px;
    text-align: center;
}

.menu-item:hover, .menu-item.active {
    background-color: #34495e;
}

.chat-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    background-color: #f5f7fa;
    overflow: hidden;
}

.chat-header {
    padding: 15px 20px;
    background-color: white;
    border-bottom: 1px solid #e1e4e8;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

/* 聊天消息区域 - 重点优化 */
.chat-messages {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: #bdc3c7 transparent;
    /* 确保滚动区域正确计算高度 */
    max-height: calc(100vh - 130px);
}

.chat-messages::-webkit-scrollbar {
    width: 8px;
}

.chat-messages::-webkit-scrollbar-thumb {
    background-color: #bdc3c7;
    border-radius: 4px;
}

.chat-messages::-webkit-scrollbar-track {
    background-color: transparent;
}

.message {
    margin-bottom: 20px;
    max-width: 70%;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.message.received {
    margin-right: auto;
}

.message.sent {
    margin-left: auto;
}

.message-content {
    padding: 12px 15px;
    border-radius: 18px;
    position: relative;
    word-wrap: break-word; /* 长文本自动换行 */
}

.received .message-content {
    background-color: white;
    border: 1px solid #e1e4e8;
    border-top-left-radius: 4px;
}

.sent .message-content {
    background-color: #3498db;
    color: white;
    border-top-right-radius: 4px;
}

.message-time {
    font-size: 12px;
    color: #7f8c8d;
    margin-top: 5px;
    text-align: right;
}

.chat-input-area {
    padding: 15px;
    background-color: white;
    border-top: 1px solid #e1e4e8;
}

.chat-form {
    display: flex;
}

.chat-input {
    flex: 1;
    padding: 12px 15px;
    border: 1px solid #bdc3c7;
    border-radius: 25px;
    font-size: 16px;
    resize: none;
    height: 50px;
    overflow-y: auto; /* 输入框内容过多时可滚动 */
}

.chat-input:focus {
    outline: none;
    border-color: #3498db;
}

.send-btn {
    margin-left: 10px;
    padding: 0 20px;
    background-color: #3498db;
    color: white;
    border-radius: 25px;
    font-weight: 500;
    transition: background-color 0.3s ease;
}

.send-btn:hover {
    background-color: #2980b9;
}

/* 订单列表样式 */
.orders-container {
    padding: 20px;
    overflow-y: auto;
    flex: 1;
    scrollbar-width: thin;
    scrollbar-color: #bdc3c7 transparent;
}

.orders-container::-webkit-scrollbar {
    width: 8px;
}

.orders-container::-webkit-scrollbar-thumb {
    background-color: #bdc3c7;
    border-radius: 4px;
}

.orders-header {
    margin-bottom: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.orders-list {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.order-card {
    background-color: white;
    border-radius: 8px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
    padding: 15px;
    transition: transform 0.2s ease;
}

.order-card:hover {
    transform: translateY(-2px);
}

.order-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 10px;
    padding-bottom: 10px;
    border-bottom: 1px solid #f1f1f1;
}

.order-id {
    font-weight: 600;
}

.order-status {
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 14px;
}

.status-paid {
    background-color: #e8f4fd;
    color: #3498db;
}

.status-shipped {
    background-color: #e6f7ef;
    color: #27ae60;
}

.status-received {
    background-color: #fff8e6;
    color: #f39c12;
}

.status-after-sales {
    background-color: #fef3f2;
    color: #e74c3c;
}

.order-details {
    margin-bottom: 10px;
}

.order-row {
    margin-bottom: 5px;
    font-size: 14px;
}

.order-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

.btn-secondary {
    padding: 6px 12px;
    background-color: #ecf0f1;
    color: #2c3e50;
    border-radius: 4px;
    font-size: 14px;
    transition: all 0.3s ease;
}

.btn-secondary:hover {
    background-color: #dcdde1;
}

.btn-danger {
    padding: 6px 12px;
    background-color: #e74c3c;
    color: white;
    border-radius: 4px;
    font-size: 14px;
    transition: all 0.3s ease;
}

.btn-danger:hover {
    background-color: #c0392b;
}

/* 管理员页面样式 */
.admin-container {
    display: flex;
    height: 100vh;
    overflow: hidden;
}

.admin-sidebar {
    width: 200px;
    background-color: #2c3e50;
    color: white;
}

.admin-content {
    flex: 1;
    display: flex;
    overflow: hidden;
}

.user-list {
    width: 250px;
    background-color: white;
    border-right: 1px solid #e1e4e8;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: #bdc3c7 transparent;
}

.user-list::-webkit-scrollbar {
    width: 6px;
}

.user-list::-webkit-scrollbar-thumb {
    background-color: #bdc3c7;
    border-radius: 3px;
}

.user-item {
    padding: 12px 15px;
    border-bottom: 1px solid #f1f1f1;
    cursor: pointer;
    transition: background-color 0.2s ease;
}

.user-item:hover, .user-item.active {
    background-color: #f5f7fa;
}

.admin-chat-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    background-color: #f5f7fa;
    overflow: hidden;
}

/* 表单样式 */
.form-container {
    background-color: white;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    padding: 25px;
    margin: 20px;
}

.form-title {
    margin-bottom: 20px;
    color: #2c3e50;
}

.form-row {
    margin-bottom: 20px;
}

.form-row label {
    display: block;
    margin-bottom: 8px;
    color: #2c3e50;
    font-weight: 500;
}

.form-control {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #bdc3c7;
    border-radius: 4px;
    font-size: 16px;
}

.form-control:focus {
    outline: none;
    border-color: #3498db;
}

.form-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 30px;
}

/* 表格样式 */
.table-container {
    overflow-x: auto;
    margin: 20px;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    background-color: white;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.data-table th, .data-table td {
    padding: 12px 15px;
    text-align: left;
    border-bottom: 1px solid #f1f1f1;
}

.data-table th {
    background-color: #f5f7fa;
    font-weight: 600;
    color: #2c3e50;
}

.data-table tr:hover {
    background-color: #f9f9f9;
}

.table-actions {
    display: flex;
    gap: 5px;
}

.action-btn {
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 12px;
}

.edit-btn {
    background-color: #3498db;
    color: white;
}

.delete-btn {
    background-color: #e74c3c;
    color: white;
}

/* 响应式调整 */
@media (max-width: 768px) {
    .chat-container {
        flex-direction: column;
    }

    .sidebar {
        width: 100%;
        height: auto;
    }

    .sidebar-menu {
        display: flex;
        overflow-x: auto;
        scrollbar-width: none;
    }

    .sidebar-menu::-webkit-scrollbar {
        display: none;
    }

    .menu-item {
        flex-direction: column;
        padding: 10px;
        flex: 1;
        text-align: center;
    }

    .menu-item i {
        margin-right: 0;
        margin-bottom: 5px;
    }

    .message {
        max-width: 85%;
    }

    .chat-messages {
        max-height: calc(100vh - 200px);
    }
}

/* 用户列表样式 */
.user-list {
    width: 250px;
    background-color: #f8f9fa;
    border-right: 1px solid #dee2e6;
    display: flex;
    flex-direction: column;
}

.user-item {
    padding: 12px 15px;
    cursor: pointer;
    display: flex;
    align-items: center;
    border-bottom: 1px solid #e9ecef;
    transition: background-color 0.2s;
}

.user-item:hover {
    background-color: #e9ecef;
}

.user-item.active {
    background-color: #e0f7fa;
    border-left: 3px solid #26c6da;
}

.user-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background-color: #e0f7fa;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-right: 12px;
}

.user-avatar i {
    color: #26c6da;
    font-size: 18px;
}

.user-info {
    flex: 1;
}

.user-name {
    font-weight: 500;
    color: #212529;
}

.user-id {
    font-size: 12px;
    color: #6c757d;
}

/* 聊天消息样式 */
.message {
    max-width: 80%;
    margin-bottom: 15px;
    padding: 10px 15px;
    border-radius: 18px;
    position: relative;
}

.message.user-message {
    background-color: #e9ecef;
    align-self: flex-start;
    border-bottom-left-radius: 5px;
}

.message.bot-message {
    background-color: #e0f7fa;
    align-self: flex-start;
    border-bottom-left-radius: 5px;
}

.message.admin-message {
    background-color: #d1ecf1;
    align-self: flex-end;
    border-bottom-right-radius: 5px;
}

.message-content {
    font-size: 14px;
    line-height: 1.5;
    word-wrap: break-word;
}

.message-time {
    font-size: 11px;
    color: #6c757d;
    text-align: right;
    margin-top: 5px;
}

/* 加载状态 */
.loading-users {
    padding: 20px;
    text-align: center;
    color: #6c757d;
}

.loading-users i {
    margin-right: 8px;
}

/* 空状态 */
.no-users, .no-messages {
    padding: 30px;
    text-align: center;
    color: #6c757d;
}

.no-users i, .no-messages i {
    font-size: 24px;
    margin-bottom: 10px;
    display: block;
}

/* 错误状态 */
.error-message {
    padding: 20px;
    text-align: center;
    color: #dc3545;
}

.error-message i {
    margin-right: 8px;
}